package com.dzl.config.interceptor;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
/**
 *
 * @Description:登录拦截器配置
 * @author liufan
 * @time:2021年4月24日 下午3:32:26
 */
@Configuration
public class LoginConfiguration implements WebMvcConfigurer {

	@Autowired
    private LoginInterceptor loginInterceptor;

	@Override
	public void addInterceptors(InterceptorRegistry registry) {
		// 拦截器已加载
		InterceptorRegistration addInterceptor = registry.addInterceptor(loginInterceptor);
		//默认拦截所有 登录接口编写之后在进行拦截
		addInterceptor
				.addPathPatterns("/**")
				.excludePathPatterns("/sysAdmin/loginVerifyPhone","/sysAdmin/loginVerifyPassword","/sysAdmin/loginSetNewPassword","/sysAdmin/logout")
				.excludePathPatterns("/getToken","/manager/sendCode")
				.excludePathPatterns("/fullReleaseApplet/**")
				.excludePathPatterns("/receiveEneterpriseWechatMsg","/welfareBase/getEnterpriseInfo")
				.excludePathPatterns("/welfareExchangeSecret/queryExchangeSecretByNumber")
				.excludePathPatterns("/welfareMovieCity/**")
				.excludePathPatterns("/welfareMovieInfo/**")
				.excludePathPatterns("/welfareMovieCinema/**")
				.excludePathPatterns("/welfareMovieOrder/updateSettlementNotify")
				.excludePathPatterns("/welfareUserWx/wxLogin","/welfareUserWx/wxVerify")
				.excludePathPatterns("/welfareUserWx/login")
				.excludePathPatterns("/welfareUserWx/getOpenid","/welfareUserWx/forgetPassword")
				.excludePathPatterns("/welfareEnterprise/getHomePageInfo","/welfareUserWx/getEnterpriseId","/welfareEnterprise/getWelfareEnterpriseInfo")
				.excludePathPatterns("/welfareGoodsAttr/**")
				.excludePathPatterns("/welfareGoodsClassify/**")
				.excludePathPatterns("/welfareMicroPage/**")
				.excludePathPatterns("/welfareAboutUs/getAboutUsInfo","/welfareGoods/**")
				.excludePathPatterns("/swagger-resources/**", "/webjars/**", "/v2/**", "/doc.html/**")
				.excludePathPatterns("/middlegroundApi/**")
				.excludePathPatterns("/blueBrothers/notify","/extractCard/notify")
				.excludePathPatterns("/welfareCalculator")
				.excludePathPatterns("/welfareOrder/updateSettlementNotify");
	}

	@Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
		//静态资源拦截
		registry.addResourceHandler("doc.html").addResourceLocations("classpath:/META-INF/resources/");
		registry.addResourceHandler("/webjars/**").addResourceLocations("classpath:/META-INF/resources/webjars/");
    }

}
